﻿import { NgModule } from '@angular/core';
import { NavigationEnd, Router, RouterModule } from '@angular/router';
import { AuditLogsComponent } from './audit-logs/audit-logs.component';
import { AccountRouteGuard } from '../../account/auth/account-route-guard';
//import { AccountRouteGuard } from './auth/account-route-guard';
import { HostDashboardComponent } from './dashboard/host-dashboard.component';
import { DemoUiComponentsComponent } from './demo-ui-components/demo-ui-components.component';
import { EditionsComponent } from './editions/editions.component';
import { InstallComponent } from './install/install.component';
import { LanguageTextsComponent } from './languages/language-texts.component';
import { LanguagesComponent } from './languages/languages.component';
import { MaintenanceComponent } from './maintenance/maintenance.component';
import { OrganizationUnitsComponent } from './organization-units/organization-units.component';
import { RolesComponent } from './roles/roles.component';
import { HostSettingsComponent } from './settings/host-settings.component';
import { TenantSettingsComponent } from './settings/tenant-settings.component';
import { InvoiceComponent } from './subscription-management/invoice/invoice.component';
import { SubscriptionManagementComponent } from './subscription-management/subscription-management.component';
import { TenantsComponent } from './tenants/tenants.component';
import { UiCustomizationComponent } from './ui-customization/ui-customization.component';
import { UsersComponent } from './users/users.component';
import { TaskComponent } from './task/task.component';
import { OutsourcingWorkflowComponent } from './outsourcingworkflow/outsourcingworkflow.component';
import { SupplierComponent } from './supplier/supplier.component';
import { TaskoutsouringComponent } from './taskoutsouring/taskoutsouring.component';
import { FlowInitProcessComponent } from './FlowInitProcess/FlowInitProcess.component';
import { FlowapplyordinarycreateComponent } from './flowapplyordinarycreate/flowapplyordinarycreate.component';
import { AdminBacklogComponent } from './backlog/backlog.component';
import { OrdinaryOutsourcingAuditComponent } from './OrdinaryOutsourcingAudit/OrdinaryOutsourcingAudit.component';
import { FlowworkauditmodelComponent } from './flowworkauditmodel/flowworkauditmodel.component';
import { MyapplyComponent } from './myapply/myapply.component';
import { OrdinaryCrucialAuditComponent } from './OrdinaryCrucialAudit/OrdinaryCrucialAudit.component';
import { OrderOutsourcedProcessingCreateComponent } from './OrderOutsourcedProcessingCreate/OrderOutsourcedProcessingCreate.component';
import { ProcessingOrderAuditComponent } from './ProcessingOrderAudit/ProcessingOrderAudit.component';
import { ProcessingDeliveryAuditComponent } from './ProcessingDeliveryAudit/ProcessingDeliveryAudit.component';
import { BaseDataItemComponent } from './BaseDataItem/BaseDataItem.component';
import { FlowConfigComponent } from './FlowConfig/FlowConfig.component';
import { CoderuleComponent } from './coderule/coderule.component';
import { OrdinaryOutsourcingDetailComponent } from './OrdinaryOutsourcingDetail/OrdinaryOutsourcingDetail.component';
import { OrdinaryCrucialDetailComponent } from './OrdinaryCrucialDetail/OrdinaryCrucialDetail.component';
import { ProcessingOrderDetailComponent } from './ProcessingOrderDetail/ProcessingOrderDetail.component';
import { ProcessingDeliveryDetailComponent } from './ProcessingDeliveryDetail/ProcessingDeliveryDetail.component';
import { OutsourcingApplicationListComponent } from './OutsourcingApplicationList/OutsourcingApplicationList.component';
import { ProcessingOrderListComponent } from './ProcessingOrderList/ProcessingOrderList.component';
import { AwaitQuotationWorkFlowComponent } from './AwaitQuotationWorkFlow/AwaitQuotationWorkFlow.component';
import { OutsourcingQuotationAuditComponent } from './OutsourcingQuotationAudit/OutsourcingQuotationAudit.component';
import { ChooseSupplierComponent } from './ChooseSupplier/ChooseSupplier.component';
import { ProcessingOrderRecordListComponent } from './ProcessingOrderRecordList/ProcessingOrderRecordList.component';
import { OutsourcingApplyChangeCreateComponent } from './OutsourcingApplyChangeCreate/OutsourcingApplyChangeCreate.component';
import { OutsourcingApplyChangeAuditComponent } from './OutsourcingApplyChangeAudit/OutsourcingApplyChangeAudit.component';
import { OutsourcingApplyChangeDetailComponent } from './OutsourcingApplyChangeDetail/OutsourcingApplyChangeDetail.component';
import { CrucialOutsourcingApplyChangeCreateComponent } from './CrucialOutsourcingApplyChangeCreate/CrucialOutsourcingApplyChangeCreate.component';
import { CrucialOutsourcingApplyChangeAuditComponent } from './CrucialOutsourcingApplyChangeAudit/CrucialOutsourcingApplyChangeAudit.component';
import { OutsourcingApplyChangeListComponent } from './OutsourcingApplyChangeList/OutsourcingApplyChangeList.component';
import { CrucialProcessingContentApplyChangeCreateComponent } from './CrucialProcessingContentApplyChangeCreate/CrucialProcessingContentApplyChangeCreate.component';
import { ProcessingContentApplyChangeCreateComponent } from './ProcessingContentApplyChangeCreate/ProcessingContentApplyChangeCreate.component';
import { OrdinaryProcessingContentApplyChangeAuditComponent } from './OrdinaryProcessingContentApplyChangeAudit/OrdinaryProcessingContentApplyChangeAudit.component';
import { CrucialProcessingContentApplyAuditComponent } from './CrucialProcessingContentApplyAudit/CrucialProcessingContentApplyAudit.component';
import { ProcessingContentApplyChangeDetailComponent } from './ProcessingContentApplyChangeDetail/ProcessingContentApplyChangeDetail.component';
import { from } from 'rxjs';
@NgModule({
    imports: [
        RouterModule.forChild([
            {
                path: '',
                children: [
                    { path: 'users', component: UsersComponent, data: { permission: 'Pages.Administration.Users' } },
                    { path: 'roles', component: RolesComponent, data: { permission: 'Pages.Administration.Roles' } },
                    { path: 'auditLogs', component: AuditLogsComponent, data: { permission: 'Pages.Administration.AuditLogs' } },
                    { path: 'maintenance', component: MaintenanceComponent, data: { permission: 'Pages.Administration.Host.Maintenance' } },
                    { path: 'hostSettings', component: HostSettingsComponent, data: { permission: 'Pages.Administration.Host.Settings' } },
                    { path: 'editions', component: EditionsComponent, data: { permission: 'Pages.Editions' } },
                    { path: 'languages', component: LanguagesComponent, data: { permission: 'Pages.Administration.Languages' } },
                    { path: 'languages/:name/texts', component: LanguageTextsComponent, data: { permission: 'Pages.Administration.Languages.ChangeTexts' } },
                    { path: 'tenants', component: TenantsComponent, data: { permission: 'Pages.Tenants' } },
                    { path: 'organization-units', component: OrganizationUnitsComponent, data: { permission: 'Pages.Administration.OrganizationUnits' } },
                    { path: 'subscription-management', component: SubscriptionManagementComponent, data: { permission: 'Pages.Administration.Tenant.SubscriptionManagement' } },
                    { path: 'invoice/:paymentId', component: InvoiceComponent, data: { permission: 'Pages.Administration.Tenant.SubscriptionManagement' } },
                    { path: 'tenantSettings', component: TenantSettingsComponent, data: { permission: 'Pages.Administration.Tenant.Settings' } },
                    { path: 'hostDashboard', component: HostDashboardComponent, data: { permission: 'Pages.Administration.Host.Dashboard' } },
                    { path: 'demo-ui-components', component: DemoUiComponentsComponent, data: { permission: 'Pages.DemoUiComponents' } },
                    { path: 'install', component: InstallComponent },
                    { path: 'ui-customization', component: UiCustomizationComponent },
                    { path: 'tasksaa', component: TaskComponent },
                    { path: 'outsourcingworkflow', component: OutsourcingWorkflowComponent },
                    { path: 'supplier', component: SupplierComponent },
                    { path: 'BaseDataItem', component: BaseDataItemComponent },
                    { path: 'taskoutsouring', component: TaskoutsouringComponent },
                    { path: 'initprocess', component: FlowInitProcessComponent },
                    { path: 'ordinarycreate', component: FlowapplyordinarycreateComponent },
                    { path: 'backlog', component: AdminBacklogComponent },
                    { path: 'OrdinaryOutsourcingAudit', component: OrdinaryOutsourcingAuditComponent },
                    { path: 'OutsourcingQuotationAudit', component: OutsourcingQuotationAuditComponent },
                    { path: 'chooseSupplier', component: ChooseSupplierComponent },
                    { path: 'flowworkauditmodel', component: FlowworkauditmodelComponent },
                    { path: 'myapply', component: MyapplyComponent },
                    { path: 'OrdinaryCrucialAudit', component: OrdinaryCrucialAuditComponent },
                    { path: 'OrderOutsourcedProcessingCreate', component: OrderOutsourcedProcessingCreateComponent },
                    { path: 'ProcessingOrderAudit', component: ProcessingOrderAuditComponent },
                    { path: 'FlowConfig', component: FlowConfigComponent },
                    { path: 'coderule', component: CoderuleComponent },

                    { path: 'ProcessingDeliveryAudit', component: ProcessingDeliveryAuditComponent },
                    { path: 'OrdinaryOutsourcingDetail', component: OrdinaryOutsourcingDetailComponent },
                    { path: 'OrdinaryCrucialDetail', component: OrdinaryCrucialDetailComponent },
                    { path: 'ProcessingOrderDetail', component: ProcessingOrderDetailComponent },
                    { path: 'ProcessingDeliveryDetail', component: ProcessingDeliveryDetailComponent },
                    { path: 'FlowConfig', component: FlowConfigComponent },
                    { path: 'OutsourcingApplicationList', component: OutsourcingApplicationListComponent },
                    { path: 'ProcessingOrderList', component: ProcessingOrderListComponent },
                    { path: 'awaitquotationworkflow', component: AwaitQuotationWorkFlowComponent },
                    { path: 'ProcessingOrderRecordList', component: ProcessingOrderRecordListComponent },
                    { path: 'OutsourcingApplyChangeCreate', component: OutsourcingApplyChangeCreateComponent},
                    { path: 'OutsourcingApplyChangeAudit', component: OutsourcingApplyChangeAuditComponent },
                    { path: 'OutsourcingApplyChangeDetail', component: OutsourcingApplyChangeDetailComponent },
                    { path: 'CrucialOutsourcingApplyChangeCreate', component: CrucialOutsourcingApplyChangeCreateComponent },
                    { path: 'CrucialOutsourcingApplyChangeAudit', component: CrucialOutsourcingApplyChangeAuditComponent },
                    { path: 'OutsourcingApplyChangeList', component: OutsourcingApplyChangeListComponent },
                    { path: 'CrucialProcessingContentApplyChangeCreate', component: CrucialProcessingContentApplyChangeCreateComponent },
                    { path: 'ProcessingContentApplyChangeCreate', component: ProcessingContentApplyChangeCreateComponent },
                    { path: 'OrdinaryProcessingContentApplyChangeAudit', component : OrdinaryProcessingContentApplyChangeAuditComponent },
                    { path: 'CrucialProcessingContentApplyAudit', component: CrucialProcessingContentApplyAuditComponent },
                    { path: 'ProcessingContentApplyChangeDetail', component: ProcessingContentApplyChangeDetailComponent}
                ]
            }
        ])
    ],
    exports: [
        RouterModule
    ]
})
export class AdminRoutingModule {

    constructor(
        private router: Router
    ) {
        router.events.subscribe((event) => {
            if (event instanceof NavigationEnd) {
                window.scroll(0, 0);
            }
        });
    }
}
